package com.unitd.base.frame.plugins.module.model;

import lombok.*;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.io.Serializable;

/**
 * 自定义的实体类的基类, 该类用于定义所有实体类的共有和通用字段,以及主键生成策略
 *
 * @author Hudan
 * @version 1.0
 * @filename MybatisBaseEntity.java
 * @copyright www.symdata.cn
 * @date 2019-01-23
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@ToString
@EqualsAndHashCode
public class MybatisBaseEntity implements Serializable, Cloneable {

	/**
	 * 自增主键ID
	 */
	@Id
	@Column(name = "ID")
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	protected Long id;
	/**
	 * 创建时间
	 */
	@Column(name = "CREATE_TIME")
	protected String createTime;
	/**
	 * 更新时间
	 */
	@Column(name = "UPDATE_TIME")
	protected String updateTime;

	public MybatisBaseEntity(Long id) {
		this();
		this.id = id;
	}

	/**
	 * 设置公共属性为空
	 */
	protected void setNull() {
		setId(null);
	}

	@Override
	public Object clone() throws CloneNotSupportedException {
		return super.clone();
	}
}